package org.apache.servicecomb.fence.resource;

import org.hibernate.Hibernate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author sweetwuxiaomei@qq.com
 * @date 2024/12/9
 */
@Service
public class StudentBizService {

  @Autowired
  private StudentRepository studentRepository;

  @Transactional
  public StudentDTO getStudentById(Long id) {
    Student student = studentRepository.findById(id).orElseThrow();
    StudentDTO studentDTO = new StudentDTO(student.getName(), student.getAge(), student.getId(), student.getClassId());
    return studentDTO;
  }
}
